'use strict';
const db = uniCloud.database();
exports.main = async (event, context) => {	
	const currentDate = new Date() 
	const year = currentDate.getFullYear() 
	const month = currentDate.getMonth() 
	const day = currentDate.getDate()
	const firstDay = new Date(year, month, day)
	const lastDay = new Date(year, month, day+1) 
	
	const order = db.collection("order");
	let res = await order.where({
		store_id: event.store_id,
		buy_time: db.command.gte(firstDay.getTime()).and(db.command.lte(lastDay.getTime()))
	}).count()
	
	return res;
};